package com.example.dou2204;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.CycleInterpolator;
import android.widget.Button;
import android.widget.ImageView;

/**
 * 讲解基础知识用，不用集合到项目中
 */
public class DemoActivity2 extends AppCompatActivity {
    private ImageView iv;
    private Button btn;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo2);
        btn = findViewById(R.id.btn);
        iv = (ImageView) findViewById(R.id.iv);
        /*AnimationDrawable background = (AnimationDrawable) iv.getBackground();
        background.start();*/
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Animation animation = AnimationUtils.loadAnimation(DemoActivity2.this, R.anim.scale);
                //Animation animation = AnimationUtils.loadAnimation(DemoActivity2.this, R.anim.translate);
                Animation animation = AnimationUtils.loadAnimation(DemoActivity2.this, R.anim.rotate);
                animation.setInterpolator(new CycleInterpolator(3));
                iv.startAnimation(animation);
            }
        });
    }
}